import  { AppPostT } from '@utils/request'
import { UserInfo, LoginInfo, AccountInfo } from '@/models/user'
import { ActionResult } from '@/models/basicType'

// 获取当前用户信息
export async function getUserInfo(skipResponseCheck: boolean = false) {
    const data = {};
    const res = await AppPostT<UserInfo>("/user/profile", data, { skipResponseCheck })
    console.log("getUserInfo request:", data, ", result:", res)
    return res.data ? res.data : {} as UserInfo
}

// 更新当前用户信息
export async function updateUserInfo(data:UserInfo) {
    const res = await AppPostT<ActionResult>("/user/updateProfile",data)
    console.log("updateUserInfo request:", data, ", result:", res)
    return res.data ? res.data : {} as ActionResult
}

// 登录
export async function login(data:LoginInfo) {
    const res = await AppPostT<AccountInfo>("/user/login",data)
    console.log("login request:", data, ", result:", res)
    return res.data ? res.data : {} as AccountInfo
}

